const express = require("express")
const cors = require("cors")
const app = express()
app.use(cors({
    origin: "http://localhost:8080",
    credentials: true,
  }));
const path = require("path")
const staticRoot = path.resolve(__dirname,"../public")

app.use(express.static(staticRoot))
app.use(express.urlencoded({extended:true}))
app.use(express.json())

const cookieParser = require("cookie-parser");
app.use(cookieParser("qmc"))

app.use(require("./tokeMiddleware"))

app.use("/api/admin",require("./api/admin.js"))
app.use("/api/message",require("./api/message.js"))
app.use("/api/blog",require("./api/blog.js"))
app.use("/api/class",require("./api/class.js"))
app.use("/api/upload",require("./api/upload.js"))


app.listen(1080,()=>{
    console.log("服务已开启:http://localhost:1080")
})